package com.ailk.kbi.kbiwarden.wsi.util;

import com.ailk.kbi.kbiwarden.wsi.service.Notify;
import com.ailk.kbi.kbiwarden.wsi.service.NotifyClient;
import com.ailk.kbi.kbiwarden.wsi.vo.SessionVO;



/**
 * 异步获取数据线程
 * @author kyunra
 *
 */
public class AsynDataThread extends Thread {

	private SessionVO sessionVO;
	
	public AsynDataThread(SessionVO sessionVO){
		this.sessionVO = sessionVO;
	}
	
	public void run() {
		println("创建XML...")
		DataUtil dataUtil = new DataUtil();
		String dataXML = dataUtil.getDataXML(sessionVO.getQueryVO());
		saveXmlContent(dataXML);
		sessionVO.isComplete = true
		println("创建XML完成！")
		if(sessionVO.getNotifyAddress()){
			Notify notifyService = new NotifyClient(sessionVO.getNotifyAddress());
			notifyService.createComplete(sessionVO.getSessionId());
		}
	}

    private void saveXmlContent(String content){
		String fileName = AsynUtil.getXmlFileName(sessionVO)
		println("创建XML文件" + fileName + "...")
    	def fw= new FileWriter(fileName)
    	fw.write(content)
        fw.close()		
    }
}
